/*
 * @Author: 朱自强
 * @Date: 2023-11-09 11:56:18
 * @LastEditors: 朱自强
 * @LastEditTime: 2023-11-09 14:59:49
 * @FilePath: \vite-project\src\router\index.ts
 * @Description:
 *
 * Copyright (c) 2023 by 朱自强, All Rights Reserved.
 */
import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router";
import Home from "../views/Home";
import VoiceInput from "../views/VoiceInput";

const routes: Array<RouteRecordRaw> = [
  {
    path: "/",
    redirect: "/voiceInput", //路由重定向
    children: [
      //路由嵌套
      {
        path: "/voiceInput",
        name: "VoiceInput",
        component: () => import("../views/VoiceInput"),
      },
    ],
  },
  {
    name: "Login",
    path: "/login",
    component: () => import("../views/Login"),
  },
  // {
  //   name: "404",
  //   path: "/:pathMatch(.*)*",
  //   component: () => import("../views/404.vue"),
  // },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

router.beforeEach((news, old, next) => {
  console.log(`路由跳转`, news, old, next);
  next();
});

export default router;
